package com.frxuexi.lib_base.utils

import android.content.Context
import android.util.Log
import com.alibaba.android.arouter.facade.Postcard
import com.alibaba.android.arouter.facade.callback.NavigationCallback
import com.alibaba.android.arouter.launcher.ARouter

class ArouterService:NavigationCallback {
    override fun onFound(postcard: Postcard?) {

    }

    override fun onLost(postcard: Postcard?) {
        Log.i("lr",postcard?.path+"路径丢失")
        ARouter.getInstance().build("/app/ErrorActivity").navigation(postcard?.context)
    }

    override fun onArrival(postcard: Postcard?) {
    }

    override fun onInterrupt(postcard: Postcard?) {
    }
}

object ArouterManager{
    fun nav(context: Context,url:String,value:Int?=-1){
        ARouter.getInstance().build(url).withInt("id",value!!).navigation(context,ArouterService())
    }
}